/*
 * 采购合同请求
 * 240716
 *
 */

import { http } from "@/utils/http";
import { baseUrlApi } from "@/store/utils";

// 获取采购合同列表
export const getProcureContractsList = (params?: object) => {
  return http.request("get", baseUrlApi("purchase/list"), { params });
};

// 删除采购合同
export const delProcureContract = (data?: object) => {
  return http.request("post", baseUrlApi("purchase/deleted"), { data });
};

// 提交审批采购合同
export const submitProcureContract = (data?: object) => {
  return http.request("post", baseUrlApi("purchase/submit/approval"), { data });
};

// 撤回采购合同
export const withdrawProcureContract = (data?: object) => {
  return http.request("post", baseUrlApi("purchase/revocation"), { data });
};

// 保存采购合同信息 - 第一页
export const saveProcureContractInfo = (data?: object) => {
  return http.request("post", baseUrlApi("purchase/save"), { data });
};

// 获取采购合同信息 - 第一页
export const getProcureContractInfo = (params?: object) => {
  return http.request("get", baseUrlApi("purchase/info"), { params });
};

// 处理审批
export const procureContractApproval = (data?: object) => {
  return http.request("post", baseUrlApi("purchase/approval"), { data });
};

// 导入合同材料
export const importMaterialList = (formData: FormData) => {
  return http.request("post", baseUrlApi("purchase/import/material/file"), {
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data" // 设置正确的请求头
    }
  });
};

// 导出合同材料
export const exportMaterialList = (params?: object) => {
  return http.request("get", baseUrlApi("purchase/export/material/file"), {
    params
  });
};
